package com.sls.game.dao.xingxitian.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.xingxitian.XingGoodsTopDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.xingqitian.XingGoodsTopInfo;

/**
 * 
 * @description
 * @author Wangxuegang
 * @date 2012-12-22
 */
@Repository("xingGoodsTopDAO")
public class XingGoodsTopDAOImpl extends SuperDAO<XingGoodsTopInfo> implements
		XingGoodsTopDAO {

	@Override
	public void insert(XingGoodsTopInfo info) {
		this.getSqlSession().insert("mybatis.xml.XingGoodsTopMapper.insert",
				info);
	}

	@Override
	public XingGoodsTopInfo queryInfoByGametype(String gametype) {
		XingGoodsTopInfo info = null;
		info = this.getSqlSession().selectOne(
				"mybatis.xml.XingGoodsTopMapper.queryInfoByGametype", gametype);
		return info;
	}

	@Override
	public Pagination<XingGoodsTopInfo> queryGoodsTopInfo(XingGoodsTopInfo info) {
		Pagination<XingGoodsTopInfo> paginationList = null;
		Integer rowCount = queryRowCount(info);
		info.calculate();
		List<XingGoodsTopInfo> list = queryParvalueInfoList(info);
		paginationList = this.queryPagination(rowCount, list, info);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(XingGoodsTopInfo info) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.XingGoodsTopMapper.queryRowCount", info);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<XingGoodsTopInfo> queryParvalueInfoList(XingGoodsTopInfo info) {
		List<XingGoodsTopInfo> list = this.getSqlSession().selectList(
				"mybatis.xml.XingGoodsTopMapper.queryXQTTopInfoList", info);
		return list;
	}

	/**
	 * 记录详情
	 * 
	 * @param id
	 * @return
	 */
	@Override
	public XingGoodsTopInfo queryTopInfoById(String id) {
		XingGoodsTopInfo info = null;
		info = this.getSqlSession().selectOne(
				"mybatis.xml.XingGoodsTopMapper.queryTopInfoById", id);
		return info;
	}

}
